<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./WEB-INF/templates/turnitup_template.xhtml"
                xmlns:p="http://primefaces.org/ui"
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                xmlns:f="http://xmlns.jcp.org/jsf/core">

    <ui:define name="top">
        <ui:include src="./WEB-INF/templates/logo_bar.xhtml"/>
        <ui:include src="./WEB-INF/templates/search_bar.xhtml"/>
        <p:breadCrumb>
            <p:menuitem outcome="index"/>
            <p:menuitem value="#{webtext.my_order}" url="#" disabled="true"/>
        </p:breadCrumb>
    </ui:define>

    <ui:define name="menu_left">
    </ui:define>

    <ui:define name="basket">
    </ui:define>

    <ui:define name="content">
        <h:panelGroup layout="block" id="content_panel">
            <h:outputText styleClass="content_title" value="#{webtext.basket}"/>
            <p:separator />
            <h:form id="my_order_form">
                <p:dataGrid var="item" columns="1" value="#{basketController.listProducts}">
                    <f:facet name="header">
                        #{webtext.basket}
                    </f:facet>
                    <p:panel>
                        <h:panelGrid columns="5" style="width: 100%" cellpadding="3">
                            <p:graphicImage name="/images/#{item.product.image}" alt="#{item.product.image}" height="90" width="80"/>
                            <h:outputText value="#{item.product.name}"/>
                            <h:outputText value="#{item.product.price} &euro;"/>
                            
                            <h:panelGrid columns="3">
                                <p:commandLink update=":my_order_form" value="+" action="#{basketController.addOne}">
                                    <f:setPropertyActionListener target="#{basketController.orderedProduct}" value="#{item}"/>
                                </p:commandLink>
                                <h:inputText readonly="true" value="#{item.quantity}"/>
                                <p:commandLink update=":my_order_form" value="-" action="#{basketController.susOne}">
                                    <f:setPropertyActionListener target="#{basketController.orderedProduct}" value="#{item}"/>
                                </p:commandLink>                              
                            </h:panelGrid>
                            <p:commandLink update=":my_order_form" value="#{webtext.remove}" action="#{basketController.removeProduct}">
                                <f:setPropertyActionListener target="#{basketController.orderedProduct}" value="#{item}"/>
                            </p:commandLink>
                        </h:panelGrid>
                    </p:panel>                
                </p:dataGrid>
                <h:outputFormat value="#{webtext.total}">
                    <f:param value="#{basketController.customerOrder.amount}"/>
                </h:outputFormat>
                <h:link value="#{webtext.back_to_shopping}" outcome="index"/>
                <p:commandButton title="#{webtext.checkout}" value="#{webtext.checkout}" action="#{basketController.checkout}"/>
            </h:form>
        </h:panelGroup>
    </ui:define>

    <ui:define name="footer">
        <ui:include src="./WEB-INF/templates/footer.xhtml"/>
    </ui:define>

</ui:composition>
